﻿namespace Service.src.com.utils.modal
{
    public class HttpResult
    {
        public int Code { get; set; }

        public bool IsSuccess { get; set; }

        public object Data { get; set; }

        public string Message { get; set; }

        public HttpResult()
        {
        }

        public HttpResult(bool IsSuccess)
        {
            Code = IsSuccess ? 1 : 0;
            IsSuccess = IsSuccess;
            Message = IsSuccess ? "Success" : "Error";
        }

        public HttpResult Success()
        {
            Code = 1;
            IsSuccess = true;
            Message = "Success";
            return this;
        }

        public HttpResult Success(object _Data)
        {
            Code = 1;
            IsSuccess = true;
            Message = "Success";
            Data = _Data;
            return this;
        }

        public HttpResult Error(string _Message = "异常了")
        {
            Code = -1;
            IsSuccess = false;
            Message = _Message;
            return this;
        }
    }
}
